package com.aod.benefit.sql;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DbHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME = "cartoes.db";
	public static final String TABLE_NAME = "cartoes";

	private static final int DATABASE_VERSION = 1;
	public static final String ID = "id";
	public static final String TIPO = "tipo";
	public static final String NUMERO = "numero";
	public static final String CPF = "cpf";
	public static final String SENHA = "senha";
	public static final String SALDO = "saldo";
	
	private static final String DATABASE_CREATE = "create table " + TABLE_NAME
			+ "( " + ID + " integer primary key autoincrement, " + TIPO
			+ " text not null, " + NUMERO + " text not null, " + CPF
			+ " text not null, " + SENHA + " text not null, " + SALDO + " text not null);";

	public DbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(DbHelper.class.getName(), "Upgrading database from version "
				+ oldVersion + " to " + newVersion
				+ ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
	}
}
